package com.xjh.utils.beanutils.config;

import com.xjh.utils.beanutils.internal.cache.BeanCopyCache;
import com.xjh.utils.beanutils.internal.factory.BeanCopierFactory;
import com.xjh.utils.beanutils.internal.javassist.JavassistBeanCopyFactory;
import com.xjh.utils.beanutils.internal.logger.Logger;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;

/**
 * Bean复制配置
 *
 * @company 湖南省安第斯信息科技有限公司, 版权所有
 * @author kevin
 * @date 2021/3/10
 */
public class BeanCopyConfig {
	
	public static enum DumpOption {
		AutoDumpNone,
		AutoDumpAtFirstCopy,
		AutoDumpAlways
	}

	private static BeanCopyConfig INSTANCE = new BeanCopyConfig();
	
	private int logLevel = Logger.LogLevelWarn;
	
	private Class<?> setClass = HashSet.class;
	private Class<?> listClass = ArrayList.class;
	private Class<?> queueClass = ArrayDeque.class;
	private Class<?> dequeClass = ArrayDeque.class;
	
	private Class<? extends BeanCopierFactory> beanCopyFactory = JavassistBeanCopyFactory.class;
	
	private DumpOption dumpOption = DumpOption.AutoDumpAtFirstCopy;
	
	private ClassLoader classLoader = null;
	
	public ClassLoader getClassLoader() {
		return classLoader;
	}

	public void setClassLoader(ClassLoader classLoader) {
		this.classLoader = classLoader;
	}

	public static BeanCopyConfig instance() {
		return INSTANCE;
	}

	public static void setBeanCopyConfig(BeanCopyConfig beanCopyConfig) {
		if( beanCopyConfig == null )
			beanCopyConfig = new BeanCopyConfig();
		BeanCopyConfig.INSTANCE = beanCopyConfig;
		BeanCopyCache.setBeanCopyConfig(beanCopyConfig);
	}

	public int getLogLevel() {
		return logLevel;
	}

	public void setLogLevel(int logLevel) {
		this.logLevel = logLevel;
	}

	public Class<?> getSetClass() {
		return setClass;
	}

	public void setSetClass(Class<?> setClass) {
		this.setClass = setClass;
	}

	public Class<?> getListClass() {
		return listClass;
	}

	public void setListClass(Class<?> listClass) {
		this.listClass = listClass;
	}

	public Class<? extends BeanCopierFactory> getBeanCopyFactory() {
		return beanCopyFactory;
	}

	public void setBeanCopyFactory(Class<? extends BeanCopierFactory> beanCopyFactory) {
		this.beanCopyFactory = beanCopyFactory;
	}

	public Class<?> getQueueClass() {
		return queueClass;
	}

	public void setQueueClass(Class<?> queueClass) {
		this.queueClass = queueClass;
	}

	public Class<?> getDequeClass() {
		return dequeClass;
	}

	public void setDequeClass(Class<?> dequeClass) {
		this.dequeClass = dequeClass;
	}

	public DumpOption getDumpOption() {
		return dumpOption;
	}

	public void setDumpOption(DumpOption dumpOption) {
		this.dumpOption = dumpOption;
	}

}
